package com.aaa.sbm.configuration;

import com.aaa.sbm.entity.EntityA;
import com.aaa.sbm.entity.EntityB;
import com.aaa.sbm.entity.EntityC;
import lombok.Data;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @FileName: MyConfig
 * @Description:
 * @Author: zhz
 * @CreateTime: 2024/4/3 15:03
 * @Version: 1.0.0
 */
//@SpringBootConfiguration
@Configuration  //相当于过去xml my-config.xml中的beans
public class MyConfig {

    /**
     * 配置一个bean
     * @return
     */
   // @Bean  //相当于<bean id/name=方法的名称 class=方法返回值的限定名>
    @Bean  //相当于<bean id/name='EntityA' class='com.aaa.sbm.entity.EntityA'>
    //@Bean("ea")  //相当于<bean id/name='ea'>
    public EntityA entityA(){
        EntityA entityA = new EntityA();
        //设置注入
        entityA.setEntityB(entityB());
        return entityA;
    }

    /**
     * 配置EntityB
     * @return
     */
    @Bean
    public EntityB entityB(){
        EntityB entityB =new EntityB();
        return entityB;
    }

    /**
     * 配置entityC
     * @return
     */
    @Bean
    public EntityC entityC(){
        EntityC entityC =new EntityC();
        return entityC;
    }

}
